#ifndef CLIENT
#define CLIENT
#include"common/blockingqueue.h"

typedef enum STATE{
    INIT,
    ONLINE,
    BUSSY,
    OFFLINE,
}STATE;

typedef struct Client{
    char name[USER_NAME_LEN+1];
    int accept_sockfd;
    int recv_sockfd;
    int send_sockfd;
    STATE state;
}Client;

#define MAX_EVENTS_NUM 128
#define INPUT_LEN 100

const int RECV_TIMEOUT;

blockingqueue* msg_queue;

list_node user_list;

pthread_mutex_t print_mutex;

pthread_mutex_t send_mutex;

pthread_rwlock_t usr_list_lock;

extern const char* BUSSY_INFO;
extern const char* REJECT_INFO;
extern const char* BATTLE_STOP_INFO;
extern const char* EMPTY_INFO;


extern Client * create_client(char* addr,u_int16_t recv_port,u_int16_t send_port);

extern Client * close_client(Client * );

extern Client * process_client(Client *);

extern Client * destory_client(Client *);

#endif